package com.hgyc.mom.mes.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hgyc.mom.common.vo.Result;
import com.hgyc.mom.core.mybatis.QueryWrapperUtil;
import com.hgyc.mom.mes.entity.SopDocument;
import com.hgyc.mom.mes.service.SopDocumentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 文档管理Controller
 *
 * @author fwj
 * @since 2025-06-18
 */
@Tag(name = "文档管理控制器", description = "文档管理控制器")
@RestController
@RequestMapping("/mes/sop/document")
public class SopDocumentController {
    @Autowired
    private SopDocumentService sopDocumentService;


    @Operation(summary = "查询文档管理树列表", description = "查询文档管理树列表")
    @PostMapping("/list")
    public Result<List<SopDocument>> pageList(@Parameter(description = "查询参数") @RequestBody SopDocument sopDocument) {
        QueryWrapper<SopDocument> wrapper = QueryWrapperUtil.build(sopDocument);
        List<SopDocument> list = sopDocumentService.list(wrapper);
        return Result.success(list);
    }

    @Operation(summary = "获取文档管理详细信息", description = "获取文档管理详细信息")
    @GetMapping(value = "/{id}")
    public Result<?> getInfo(@Parameter(description = "文档管理ID") @PathVariable("id") Long id) {
        return Result.success(sopDocumentService.getById(id));
    }

}